package com.resign.carl.strategy.api;

import com.resign.carl.strategy.api.FlyBehavior;
import com.resign.carl.strategy.api.QuackBehavior;

/**
 * Created by carl.zhao on 2016/6/13.
 */
public abstract class Duck {

    protected QuackBehavior quackBehavior;

    protected FlyBehavior flyBehavior;

    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }

    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    public void performQuack(){
        quackBehavior.quack();
    }

    public void performFly(){
        flyBehavior.fly();
    }

    public void swim(){
        System.out.println("All ducks float, even decoys!");
    }

    public abstract void display();
}
